﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Media;

namespace GlobalGameJam
{
    class PauseMenuScreen : AMenuScreen
    {
        public PauseMenuScreen()
            : base("Paused")
        {
            MenuEntry resumeGameMenuEntry = new MenuEntry("Resume Game");
            MenuEntry optionMenuScreenEntry = new MenuEntry("Option");
            MenuEntry quitGameMenuEntry = new MenuEntry("Quit Game");

            resumeGameMenuEntry.Selected += OnCancel;
            optionMenuScreenEntry.Selected += OptionScreenMenuEntrySelected;
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;

            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(optionMenuScreenEntry);
            MenuEntries.Add(quitGameMenuEntry);
            name = "PauseMenu";
        }

        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Sure you wanna quit this game ? :(";

            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);
            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }

        void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            //A modif avec la classe Load;
            if (OptionsMenuScreen.CurrentMusic == 0 && MediaPlayer.State == MediaState.Playing)
            {
                Console.WriteLine("Rageux");
                MediaPlayer.Stop();
            }
            ScreenManager.RemoveScreenByName("GameplayScreen");
            ExitScreen();
            //ScreenManager.AddScreen(new StartMenuScreen(), e.PlayerIndex);
            //LoadingScreen.Load(ScreenManager, false, null, new StartMenuScreen());
        }

        void OptionScreenMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
        }
    }
}
